package com.easy.config;

import com.easy.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Component
@Configuration
public class WebConfig implements WebMvcConfigurer {

    public static final String STATIC_PATH="/img/";
    public static final String STATIC_DIR="D:\\uploadfile\\";

    @Autowired
    LoginInterceptor loginInt;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {


        registry.addResourceHandler(STATIC_PATH+"**").addResourceLocations("file:"+STATIC_DIR);
    }

//配置拦截器，让拦截器生效
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(new LoginInterceptor());//   /a/123
//     registry.addInterceptor(loginInt).addPathPatterns("/");
//        .excludePathPatterns("/dologin","/register","/checktoken","/userimg");
    }
}
